home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3127 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.1 KB

  1. Path: news.rwth-aachen.de!news
  2. From: Sebastian Brandt <csb>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: HELP!!! - loop control problems
  5. Date: 22 Jan 1996 12:47:49 GMT
  6. Organization: RWTH -Aachen / Rechnerbetrieb Informatik
  7. Message-ID: <4e011l$a7f@news.rwth-aachen.de>
  8. References: <4ds174$6t0@bolivia.it.earthlink.net> <3101abf0.164809733@news.primenet.com>
  9. NNTP-Posting-Host: marlowe.informatik.rwth-aachen.de
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.12 (X11; I; SunOS 5.4 sun4m)
  14. X-URL: news:3101abf0.164809733@news.primenet.com
  15.  
  16. > trying: const long SCREEN_SIZE = (long) 320 * 200;
  17. The idea proposed won't work on normal 16-bit-compilers, because the conversion
  18. to "long" still takes place after calculating the result of 64000, i.e. -1535
  19. (or something like it).
  20. To solve the problem, both values have to be converted before you multiply:
  21.  
  22. either
  23.     const long SCREEN_SIZE = ((long) 320) * ((long)200);
  24.  
  25. or - as both values are constant expressions -
  26.     const long SCREEN_SIZE = 300L * 200L;
  27.  
  28. I agree, is's just waful 16-bit code, you should see my Win3.1-progs using long
  29. bitshifts.
  30.  
  31.